--Playermodel selection menu

function GM:ShowSpare1( )
	local pModelL = LocalPlayer().LambModel
	local pModelC = LocalPlayer().CombModel
	--This is temporary, until i can figure out a better way of doing it...
	PlayerModelsLambda = { "Group03/female_01.mdl", "Group03/female_02.mdl", "Group03/female_03.mdl", "Group03/female_04.mdl", 
		"Group03/female_06.mdl", "Group03/female_07.mdl", "Group03/male_01.mdl", "Group03/male_02.mdl", "Group03/male_03.mdl", 
		"Group03/male_04.mdl", "Group03/male_05.mdl", "Group03/male_06.mdl", "Group03/male_07.mdl", "Group03/male_08.mdl", 
		"Group03/male_09.mdl" }
	PlayerModelsCombine = { "Combine_Soldier.mdl", "Combine_Soldier_PrisonGuard.mdl", "Combine_Super_Soldier.mdl", "Police.mdl" }
	if ( IsValid(self.PlayerModelFrame) ) then return end

	self.PlayerModelFrame = vgui.Create( "DFrame" )
	self.PlayerModelFrame:SetTitle( "Select Your Character" )
	self.PlayerModelFrame:SetSize( 510, 380 )
	self.PlayerModelFrame:Center( )
	self.PlayerModelFrame:MakePopup( )
	self.PlayerModelFrame:SetKeyboardInputEnabled( false )

		--Lambda model selection
		local LambPanel = vgui.Create( "DPanel", self.PlayerModelFrame )
		LambPanel:SetPos( 10, 35 )
		LambPanel:SetSize( 210, 270 )
		LambPanel.Paint = function()
			surface.SetDrawColor( 25, 25, 25, 200 )
			surface.DrawRect( 0, 0, LambPanel:GetWide( ), LambPanel:GetTall( ) )
			surface.SetDrawColor( 255, 255, 255, 255 )
			surface.DrawOutlinedRect(0, 0, LambPanel:GetWide( ), LambPanel:GetTall( ) )
		end

			local Licon = vgui.Create( "DModelPanel", LambPanel )
			Licon:SetPos( 0, 60 )
			Licon:SetModel( "models/player/" .. LocalPlayer().LambModel )
			Licon:SetSize( 200, 200 )
			Licon:SetCamPos( Vector( 55, 0, 100 ) )
			Licon:SetLookAt( Vector( 0, 0, 50 ) )

			local LambLabel = vgui.Create( "DLabel", LambPanel)
			LambLabel:SetText("Lambda Team Model")
			LambLabel:SetPos( 20, 5 )
			LambLabel:SizeToContents( )

			local LambModels = vgui.Create( "DMultiChoice", LambPanel)
			LambModels:SetPos( 20, 25 )
			LambModels:SetSize( 125, 20 )
			for k,v in pairs( PlayerModelsLambda ) do
				LambModels:AddChoice( v )
			end
			LambModels:SetText( LocalPlayer( ).LambModel )
			LambModels.OnSelect = function( panel,index,value )
				Licon:SetModel( "models/player/" .. value )
				pModelL = value
			end

		--Combine model selection
		local CombPanel = vgui.Create( "DPanel", self.PlayerModelFrame )
		CombPanel:SetPos( 290, 35 )
		CombPanel:SetSize( 210, 270 )
		CombPanel.Paint = function()
			surface.SetDrawColor( 25, 25, 25, 200 )
			surface.DrawRect( 0, 0, CombPanel:GetWide( ), CombPanel:GetTall( ) )
			surface.SetDrawColor( 255, 255, 255, 255 )
			surface.DrawOutlinedRect(0, 0, CombPanel:GetWide( ), CombPanel:GetTall( ) )
		end

			local Cicon = vgui.Create( "DModelPanel", CombPanel )
			Cicon:SetPos( 0, 60 )
			Cicon:SetModel( "models/player/" .. LocalPlayer( ).CombModel )
			Cicon:SetSize( 200, 200 )
			Cicon:SetCamPos( Vector( 55, 0, 100 ) )
			Cicon:SetLookAt( Vector( 0, 0, 50 ) )

			local CombLabel = vgui.Create( "DLabel", CombPanel)
			CombLabel:SetText( "Combine Team Model" )
			CombLabel:SetPos( 20, 5 )
			CombLabel:SizeToContents( )
	
			local CombModels = vgui.Create( "DMultiChoice", CombPanel)
			CombModels:SetPos( 20, 25 )
			CombModels:SetSize( 125, 20 )
			for k,v in pairs( PlayerModelsCombine ) do
				CombModels:AddChoice( v )
			end
			CombModels:SetText( LocalPlayer( ).CombModel )
			CombModels.OnSelect = function( panel, index, value )
				Cicon:SetModel( "models/player/" .. value )
				pModelC = value
			end

	local Team = vgui.Create( "DButton", self.PlayerModelFrame )
	Team:SetPos( 370, 330 )
	Team:SetSize( 130, 40 )
	Team:SetText( "Save Settings" )
	function Team.DoClick( ) 
		self:HideSpare1( )
		--3141 is a secret code to validate that the playermodel was not set from the player trying to type in the console and breaking the gamemode.
		RunConsoleCommand( "db_set_player_settings", "3141", pModelL, pModelC )
	end
end

function GM:HideSpare1( )

	if ( IsValid( self.PlayerModelFrame ) ) then
		self.PlayerModelFrame:Remove( )
		self.PlayerModelFrame = nil
	end

end